package edu.infomatik.tundra.model;

import java.util.ArrayList;
import java.util.List;

import org.apache.tapestry5.OptionGroupModel;
import org.apache.tapestry5.OptionModel;
import org.apache.tapestry5.util.AbstractSelectModel;

import edu.infomatik.tundra.logic.UStoryBean;
import edu.infomatik.tundra.logic.WorkKinds;

public class StoryIdSelectModel extends AbstractSelectModel {
	
	private List<UStoryBean> stories;
	
	public StoryIdSelectModel(List<UStoryBean> stories){
		this.stories = stories;
	}

	@Override
	public List<OptionGroupModel> getOptionGroups() {
		return null;
	}

	@Override
	public List<OptionModel> getOptions() {
		
		if (null != stories){
			List<OptionModel> list = new ArrayList<OptionModel>();
			
			for(UStoryBean wb:stories)
				if (wb.getKind()==WorkKinds.USTORY_VALUE)
					list.add(new StoryIdOptionModel(wb));
			
			return list;
		}
		return null;
	}

}
